package com.fc.h5dispaly.h5display.home.v;

import android.content.Context;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

/**
 * Created by fc on 2018/8/6.
 */

public class HomeLayout extends FrameLayout {
    private ViewPager mViewPager;
    private Context mContext;

    public static int TEXT_UN_FOCUS__COLOR = Color.parseColor("#CCCCCC");
    public static int FOCUS__COLOR = Color.parseColor("#3888D7");

    public HomeLayout(@NonNull Context context) {
        super(context);
        mContext = context;
        setBackgroundColor(Color.parseColor("#1b1d27"));
        initView();
    }

    private void initView() {
        mViewPager = new ViewPager(mContext);
        LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        addView(mViewPager, params);
        mViewPager.setAdapter(new MyPageAdapter());

    }


    class MyPageAdapter extends PagerAdapter{

        @Override
        public int getCount() {
            return 120;
        }

        @Override
        public boolean isViewFromObject(View view, Object object) {
            return view == object;
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position) {
            HomeImageLayout imageLayout = new HomeImageLayout(mContext);
            container.addView(imageLayout);
            return imageLayout;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);
        }

    }
}
